<template>
	<view class="container">
		<scroll-list :list="list" :isrefresh='isrefresh' :isreachBottom="isreachBottom"></scroll-list>
	</view>
</template>
<script>
	import {
		searchList
	} from '@/api/art.js'
	import HttpSatus from '@/commons/constants/HttpStatus.js'
	import ScrollList from '@/componts/common/ScrollList/scroll-list.vue'
	export default {
		data() {
			return {
				isrefresh: 1,
				isreachBottom: 1,
				list: [{
						artPhoto: "https://img1.baidu.com/it/u=4204817206,15390844&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500",
						avatar: "https://img2.baidu.com/it/u=974038821,3597329702&fm=253&fmt=auto&app=138&f=JPEG?w=521&h=500",
						username: "德莱厄斯",
						likeCount: 9999,
						title: "昭，你从我的战斗中看到了什么？不要以为是我的儿子，或者流着我的血，就能得到天下的拥戴！每天以磨练自己，增长才识，识尽天下万物为要务！要统领天下，就要有比别人更高的目标！是这样吧，曹孟德啊。"
					},
					{
						artPhoto: "https://img2.baidu.com/it/u=3214362833,2846753221&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500",
						avatar: "https://img2.baidu.com/it/u=3717359169,699821506&fm=253&fmt=auto&app=138&f=JPEG?w=501&h=500",
						username: "疾风剑豪",
						likeCount: 1314,
						title: "人生太过于坚强，凡事都不柔软，凡事都不退让，凡事都不回避，凡事都不思考，大脑运转迟缓，俗称一根筋，那不是坚强，那是执着，那也是造成生活苦恼的来源。松松的看别人，能忘就忘了吧。"
					},
					{
						artPhoto: "https://img1.baidu.com/it/u=2956729074,324743534&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750",
						avatar: "https://img2.baidu.com/it/u=3281844457,1839099443&fm=253&fmt=auto&app=138&f=JPEG?w=502&h=500",
						username: "影流之主",
						likeCount: 1314,
						title: "如果你的竞争对手正面对困境，那就去拉拢他的大客户。如果这些客户感觉到原来的产品质量下降了或是害怕服务会中断，他们可能会愿意转向你。！"
					},
					{
						artPhoto: "https://img0.baidu.com/it/u=1728071521,474726664&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889",
						avatar: "https://img1.baidu.com/it/u=2852616194,3051069242&fm=253&fmt=auto&app=138&f=JPEG?w=508&h=500",
						username: "放逐之刃",
						likeCount: 1314,
						title: "年少轻狂，等于慢性自杀。"
					},
					{
						artPhoto: "https://img2.baidu.com/it/u=3916863077,2902504804&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500",
						avatar: "https://img2.baidu.com/it/u=1418259588,2896116588&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
						username: "无双剑姬",
						likeCount: 1314,
						title: "浓浓的情谊，传递着博友的真诚。相互的。问候，温暖着快乐的人生。博客的相识，不仅仅是缘分，更是一首交流的乐曲！愿幸福常在您身边，愉悦常在彼此心间！祝博友周末快乐！！"
					}
				]
			}
		},
		onLoad() {
			uni.startPullDownRefresh();
			this.getSearchList()
		},
		components: {
			'scroll-list': ScrollList
		},
		onPullDownRefresh() {
			let _self = this
			setTimeout(function() {
				_self.isrefresh++
				uni.stopPullDownRefresh()
			}, 1000);
		},
		onReachBottom() {
			this.isreachBottom++;
			for (let i = 0; i < 6; i++) {
				let index = this.$u.random(0, this.list.length - 1);
				let item = JSON.parse(JSON.stringify(this.list[index]));
				item.likeCount = Math.floor(Math.random() * 1000 + 1);
				this.list.push(item)
			}
		},
		methods: {
			async getSearchList() {
				let response = await searchList();
				if(response.code == HttpSatus.SUCCESS) {
					this.list = response.data.artSearchModelList
				}
			},
		}
	}
</script>
<style lang="scss" scoped>
</style>